home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1996 #6 / Amiga Plus CD - 1996 - No. 06.iso / pd / netz / amigancp1.8 / developer / source / ncplib / openncp.c next >
C/C++ Source or Header  |  1995-11-08  |  1KB  |  60 lines

  1. /*
  2. **    SAS/C 6.51 constructor for opening
  3. **  "ncp.library"
  4. **/
  5.  
  6. #include <constructor.h>
  7. #define __USE_SYSBASE
  8. #include <proto/exec.h> 
  9. #include <exec/execbase.h>
  10. #include <proto/intuition.h>
  11. #include <proto/dos.h>
  12. #include <libraries/ncplib.h>
  13. #include <string.h>
  14. struct Library *NCPBase;
  15. static struct Library *libbase;
  16.  
  17. CONSTRUCTOR_P(ncplib,500)
  18. {
  19.     struct EasyStruct eas;
  20.     char buffer[ 128 ];
  21.     struct Task *pr = FindTask( NULL );
  22.  
  23.     if( SysBase->LibNode.lib_Version < 37 )
  24.         return( 1 );
  25.  
  26.     FOREVER
  27.     {
  28.         libbase = OpenLibrary( NCP_NAME, NCP_VERSION );
  29.         if( !libbase )
  30.             libbase = OpenLibrary( "PROGDIR:" NCP_NAME, NCP_VERSION );
  31.         if( !libbase )
  32.             libbase = OpenLibrary( "PROGDIR:Libs/" NCP_NAME, NCP_VERSION );
  33.         if( libbase )
  34.         {
  35.             NCPBase = libbase;
  36.             return( 0 );
  37.         }
  38.  
  39.         eas.es_StructSize = sizeof( eas );
  40.         eas.es_Flags = 0;
  41.         eas.es_Title = buffer;
  42.         buffer[ 127 ] = 0;
  43.         if( !GetProgramName( buffer, 127 ) )
  44.             strncpy( buffer, pr->tc_Node.ln_Name, 127 );
  45.         eas.es_TextFormat = "Requires V%ld (or higher))\nof \"" NCP_NAME "\"";
  46.         eas.es_GadgetFormat = "Retry|Cancel";
  47.         if( !EasyRequest( NULL, &eas, NULL, NCP_VERSION ) )
  48.             return( 1 );
  49.    }
  50. }
  51.  
  52. DESTRUCTOR_P(ncplib,500)
  53. {
  54.    if (libbase)
  55.    {
  56.       CloseLibrary((struct Library *)libbase);
  57.       libbase = NCPBase = NULL;
  58.    }
  59. }
  60.